<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >

	<h:form id="frm1">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="rightsPanel" style="margin-bottom:1px" header="基于基本权限的用户授权管理"			
			footer="选定某个用户，选择要授予的权限，按下Ctrl键可以多选。点击授予选定权限按钮即可。">
			
			<p:commandButton value="刷新数据" icon="ui-icon-refresh" actionListener="#{sysUserAuthMB.refreshAction()}" update=":tabview:frm1" />		
			<h:outputText id="userno" value="&nbsp;&nbsp;&nbsp;&nbsp;【当前选择的用户： #{sysUserAuthMB.userno}】&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" style="font-size:16px;color:blue" />
			<p:commandButton value="授予选定权限" icon="ui-icon-check" action="#{sysUserAuthMB.authAction()}" update=":tabview:frm1:msgs1 :tabview:frm1:dtauthority :tabview:frm1:dtsetted">
				<p:confirm header="授权确认" message="确认授予该用户选定的权限?" icon="ui-icon-alert" />
			</p:commandButton>
			<p:commandButton value="回收选定权限" icon="ui-icon-trash" action="#{sysUserAuthMB.revokeAction()}" update=":tabview:frm1:msgs1 :tabview:frm1:dtauthority :tabview:frm1:dtsetted">
				<p:confirm header="回收确认" message="确认回收该用户选定的权限?" icon="ui-icon-alert" />
			</p:commandButton>
			
			<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" width="200px" height="40px">
	        	<p:commandButton value="确认" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
	        	<p:commandButton value="取消" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
	   		</p:confirmDialog>
	   		
		<h:panelGrid columns="2" cellspacing="20" >
   		
		<p:dataTable id="dtuser" var="row"	value="#{sysUserAuthMB.voSysUsers}" 
			selectionMode="single" selection="#{sysUserAuthMB.selectedUser}" rowKey="#{row.id}" 
			resizableColumns="true" liveResize="true" style="margin-bottom:1px;" 
			emptyMessage="没有记录" scrollable="true" scrollHeight="120">					
			<f:facet name="header">用户信息</f:facet>
					
	        <p:ajax event="rowSelect" listener="#{sysUserAuthMB.onUserRowSelect}" update=":tabview:frm1" />
	        <p:ajax event="rowUnselect" listener="#{sysUserAuthMB.onUserRowUnselect}" update=":tabview:frm1:msgs1 :tabview:frm1:userno" />
												
			<p:column headerText="帐号" sortBy="#{row.userno}">
				<h:outputText value="#{row.userno}" />
			</p:column>	
			
			<p:column headerText="用户名称">
				<h:outputText value="#{row.username}" />
			</p:column>
							
		</p:dataTable>	
		
		<p:dataTable id="dtauthority" var="arow"	value="#{sysUserAuthMB.voSelections}"
			selectionMode="multiple" selection="#{sysUserAuthMB.voSelected}" rowKey="#{arow.id}"
			resizableColumns="true" liveResize="true" style="margin-bottom:1px;"
			emptyMessage="没有记录" scrollable="true" scrollHeight="122">					
			<f:facet name="header">可设置权限</f:facet>	
				
	        <p:ajax event="rowSelect" listener="#{sysUserAuthMB.onAuthRowSelect}" update=":tabview:frm1:msgs1 :tabview:frm1:dtsetting" />
	        <p:ajax event="rowUnselect" listener="#{sysUserAuthMB.onAuthRowUnselect}" update=":tabview:frm1:msgs1 :tabview:frm1:dtsetting" />
												
			<p:column headerText="权限ID" sortBy="#{arow.id}">
				<h:outputText value="#{arow.id}" />
			</p:column>	
			
			<p:column headerText="权限名称">
				<h:outputText value="#{arow.name}" />
			</p:column>
							
		</p:dataTable>				 

		<p:dataTable id="dtsetted" var="urow"	value="#{sysUserAuthMB.voSetted}"
			selectionMode="multiple" selection="#{sysUserAuthMB.voSelected}" rowKey="#{urow.id}"
			resizableColumns="true" liveResize="true" style="margin-bottom:1px;"
			emptyMessage="没有记录" scrollable="true" scrollHeight="122">					
			<f:facet name="header">用户已有权限</f:facet>	
				
	        <p:ajax event="rowSelect" listener="#{sysUserAuthMB.onAuthoredRowSelect}" update=":tabview:frm1:msgs1 :tabview:frm1:dtsetting" />
	        <p:ajax event="rowUnselect" listener="#{sysUserAuthMB.onAuthoredRowUnselect}" update=":tabview:frm1:msgs1 :tabview:frm1:dtsetting" />
												
			<p:column headerText="权限ID" sortBy="#{urow.id}">
				<h:outputText value="#{urow.id}" />
			</p:column>	
			
			<p:column headerText="权限名称">
				<h:outputText value="#{urow.name}" />
			</p:column>
							
		</p:dataTable>				 
 
		<p:dataTable id="dtsetting" var="srow"	value="#{sysUserAuthMB.voSelected}"
			resizableColumns="true" liveResize="true" style="margin-bottom:1px;"				
			emptyMessage="没有记录" scrollable="true" scrollHeight="122">					
			<f:facet name="header">已选择待设置权限</f:facet>		
												
			<p:column headerText="权限ID" sortBy="#{srow.id}">
				<h:outputText value="#{srow.id}" />
			</p:column>	
			
			<p:column headerText="权限名称">
				<h:outputText value="#{srow.name}" />
			</p:column>
							
		</p:dataTable>				 
		
		</h:panelGrid>
		
		</p:panel>
	</h:form>

</ui:composition>

